<?php
/**
 * Created by JetBrains PhpStorm.
 * User: abdelrahman
 * Date: 7/7/13
 * Time: 1:38 PM
 * To change this template use File | Settings | File Templates.
 */

class Statement
{
    /** @var PDOStatement */
    private $stmt;
    /** @var  PDO */
    private $conn;

    /**
     * @param string $string
     */
    public function __construct($string)
    {
        $this->conn = new Connection();
        $this->stmt = $this->conn->prepare($string);
    }

    /**
     * @param array $values
     */
    public function execute($values)
    {
        $this->stmt->execute($values);
    }

    /**
     * @return bool|mixed
     */
    public function fetch()
    {
        if (($row = $this->stmt->fetch()) != false)
            return $row;
        else
        {
            $this->stmt->closeCursor();
            return false;
        }
    }

    public function closeCursor()
    {
        $this->stmt->closeCursor();
    }
}